/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once


#include "引擎枚举数据.h"
#include "底层绘图/底层绘图框架.h"
#include "S_Object.h"

#include "Input/Input.h"
#include "UI/UI.h"





typedef struct {
	S_结构指针* m_Window;
	S_输入环境		m_Input;
}S_屏幕;


struct S_Window : public C_Widget {

	S_输入环境*		m_Input;
	S_结构指针		m_窗口钩柄;
	S_绘图框架*		m_绘图框架;
	S_设备环境*     m_Ctx;

	struct S_sdl_window* m_sdl_window;
	//S_Frame2D* m_ui_sruface;

	S_2D画布*		m_ui渲染画布;
	S_2D画布*		m_ui合成画布;
	S_Surface2D*	m_ui合成平面;
	S_Surface2D*	m_ui测试文字;
	S_Surface2D*	m_ui测试文字F;
	S_Surface2D*	m_ui合成;

	

	C_Widget管理*	m_窗口GM;
	E_MS次数		m_采样;
	bool			m_是否有焦点;
	bool            m_绘制;
	bool			m_处理输入事件;

	clock_t			m_时间start;
	clock_t			m_时间end;


	void*		m_Window;
	S_渲染环境*	m_绘图环境;

	std::string	m_库路径;
	float32		m_帧数;
	bool		m_弹出窗口;
	ivec2		m_PDI;

	S_Window(S_设备环境& Ctx);
	~S_Window();


	uint64	f_创建窗口(std::string 标题, int32 x = 0, int32 y = 0, int32 w = 1024, int32 h = 576, bool 显示 = false, std::string path="");
	void	f_窗口重置();
	bool	f_轮询窗口事件(bool& 累计渲染);
	void	f_显示(bool s = false);
	void	f_创建绘制面(S_设备环境& dev, ivec2 viewSize);
	void	f_创建绘制面(S_绘图框架* frame);
	ivec2	f_getSize();


	void f_set标题(std::wstring 标题);
	void f_安装UI(C_Widget* ui);
	void f_清除UI();

	//bool f_暂停刷新();

private:
	//WNDCLASS wc;

};


void f_window_创建SDL窗口(S_Window* window, std::string 标题, vec2 size);



